export function debounce(fn, delay = 200) {
  var timer = null;
  return function () {
    var args = arguments;
    var that = this;
    clearTimeout(timer);
    timer = setTimeout(() => {
      fn.apply(that, args);
    }, delay);
  };
}

const debounce2 = (fn, delay) => {
  let timer;
  return () => {
    if (timer) clearTimeout(timer);
    timer = setTimeout(fn, delay);
  };
};
